﻿using System.Text.RegularExpressions;

namespace Complaint.Models.Dtos.Validators
{
    public class EmailValidator
    {
        static readonly Regex EmailRegex = new Regex(@"^(?:[a-zA-Z0-9_'^&amp;/+-])+(?:\.(?:[a-zA-Z0-9_'^&amp;/+-])+)*@(?:(?:\[?(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))\.){3}(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\]?)|(?:[a-zA-Z0-9-]+\.)+(?:[a-zA-Z]){2,}\.?)$");
        public static bool IsValidEmail(string email)
        {
            if (!string.IsNullOrEmpty(email))
                return EmailRegex.IsMatch(email);
            return false;
        }
    }
}
